package com.neusoft.weekreport.component.controller;

import com.neusoft.weekreport.component.bizService.TaskBizService;
import com.neusoft.weekreport.component.req.GetTaskInfoListReq;
import com.neusoft.weekreport.component.resp.GetTaskInfoListResp;
import com.neusoft.weekreport.component.resp.ResponseBean;
import org.springframework.http.HttpStatus;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@EnableTransactionManagement
@RequestMapping("/task")
public class TaskController {

    @Resource
    TaskBizService taskBizService;

    //查询有效项目
    @RequestMapping(value = "/validTask",method = RequestMethod.GET)
    public ResponseBean<GetTaskInfoListResp> getValidTask(GetTaskInfoListReq req, HttpServletRequest request){
        ResponseBean<GetTaskInfoListResp> responseBean = new ResponseBean<>();
        try{
            GetTaskInfoListResp resp = taskBizService.getValidTaskInfoList(req);
            responseBean = new ResponseBean(HttpStatus.OK.value(),"查询有效项目列表成功",resp);
        }catch (Exception e){
            responseBean.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
            responseBean.setMsg(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase());
        }
        return  responseBean;
    }
}
